<?php
/*
 * program:	均源
 * author:	雨中漫步 & 上善若水 & qhxin
 * email:	qhxin@qhxin.com
 * date:	2014/11/11
 * description:	又是一年双十一，不能剁手，就写点东西吧~~~~~~
 */

defined('IN_SCHOOL') or die();

/*{TranslateTagBegin}*/
class model_subrpl extends base_model{

	//hook mod_subrpl_start.php
	private $table;

	function __construct() {
		//hook mod_subrpl_init_init_before.php
		parent::__construct();
		$this->table = 'subrpl';
		//hook mod_subrpl_init_init_end.php
	}
	
	public function subrpl_get($rid) {
		//hook mod_subrpl_subrpl_get.php
		return $this->db->get($this->table.'-rid-'.$rid);
	}

	public function subrpl_add($fid = 0, $uid = 0, $content = '',$ffid = 0) {
		$rid = $this->db->maxid($this->table.'-rid', '+1');
		//hook mod_subrpl_subrpl_add.php
		return $this->db->set( $this->table.'-rid-'.$rid, 
					array(	'rid'=>$rid,'fid'=>$fid,'ffid'=>$ffid,'uid'=>$uid,
							'content'=>$content));
	}
	
	public function subrpl_del($ffid) {
		//hook mod_subrpl_subrpl_del.php
		return $this->db->delete($this->table.'-ffid-'.$ffid);
	}

	public function subrpl_del_one($rid) {
		//hook mod_subrpl_subrpl_del_one.php
		return $this->db->delete($this->table.'-rid-'.$rid);
	}

	public function subrpl_del_by_fid($fid) {
		//hook mod_subrpl_subrpl_del_by_fid.php
		return $this->db->delete($this->table.'-fid-'.$fid);
	}

	public function subrpl_edit($rid , $str) {
		//hook mod_subrpl_subrpl_edit.php
		return $this->db->update( $this->table.'-rid-'.$rid,
				array('content'=>"$str") );
	}
	
	public function subrpl_list($fid = 0, $start = 0, $limit = 0 ,$order = -1) {
		$ret = array();
		if($fid < 1)
			return $ret;
		$arr = $this->db->index_fetch($this->table , 'rid'
										, array('fid'=>$fid), array('rid'=> $order)
										, $start, $limit);
		//hook mod_subrpl_subrpl_list.php
		return $arr;
	}

	public function subrpl_of_users_list($uid = 0, $start = 0, $limit = 0 ,$order = -1) {
		$arr = $this->db->index_fetch($this->table , 'rid'
										, array('uid'=>$uid), array('rid'=> $order)
										, $start, $limit);
		//hook mod_subrpl_subrpl_of_users_list.php
		return $arr;
	}
	
	public function subrpl_of_users_count($uid) {
		//hook mod_subrpl_subrpl_of_users_count.php
		return $this->db->index_count($this->table, array('uid'=>$uid));
	}

	//hook mod_subrpl_end.php
}
/*{TranslateTagEnd}*/

?>